package Text33;

import java.util.*;

public class Main {
    static int N = 100010;
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] w = new int[N];
        for (int i = 0; i < n; i++) {
            w[i] = scanner.nextInt();
        }
        Arrays.sort(w, 0, n);
        long res = 0;
        for (int i = 0; i < n; i++) {
            res += w[i]*(n - 1 - i);
        }
        System.out.println(res);
    }
}